package com.ruoyi.business.job;

import com.ruoyi.business.service.IOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class AutoFinshedOrderJob {
    @Autowired
    private IOrderInfoService orderInfoService;

    //凌晨一点执行该方法 查询7天前的列表，修改时间和订单状态
//    @Scheduled(cron = "0 0 1 * * ?")
//    @Scheduled(cron = "0 0/5 * * * ?")
    @Scheduled(cron = "0 0/30 * * * ?")
    public void autoFinshedOrder() {
        //拿到当前时间-7天的时间
        LocalDateTime sevenDateTime = LocalDateTime.now().minusDays(7);
        //根据时间查询要关单的订单列表
        orderInfoService.autoFinshedOrder(sevenDateTime);
    }
}
